﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MySql.Data.MySqlClient;

/// <summary>
/// Descripción breve de ServicioBL
/// </summary>
public class ServicioBL
{

    public List<string> ObtenerServicios(int idDepartamento)
    {
        List<string> servicios = new List<string>();

        string query = "SELECT nombre FROM servicios WHERE id_departamento = " + idDepartamento;
        MySqlConnection myConnection = new MySqlConnection();
        myConnection.ConnectionString = "Persist Security Info=False;Username=root;Password=;database=helpdeskdb;server=localhost;Connect Timeout=30";
        myConnection.Open();

        //create command and assign the query and connection from the constructor
        MySqlCommand cmd = new MySqlCommand(query, myConnection);
        //Execute command
        cmd.ExecuteNonQuery();
        //close connection
        MySqlDataReader dataReader = cmd.ExecuteReader();
        //Read the data and store them in the list
        while (dataReader.Read())
        {

            servicios.Add((string)dataReader["nombre"]);

        }

        //close Data Reader
        dataReader.Close();
        //close Connection
        myConnection.Close();

        return servicios;
    }
}